const fileTypeMatch = (filename) => {
    let extname = filename.match(/\.[^\.]+$/)[0];
    return getFileType(extname)
}
const getFileType = (extname) => {
    var e_img = ['.pic', '.bmp', '.jpg', '.jpeg', '.png', '.gif', '.dib', '.rle', '.emf', '.jif', '.pcx', '.tga', '.tif', '.wmf','.jfif'];
    var e_video = [".mp4", ".avi", ".mov", ".asf", ".wmv", ".navi", ".3gp", ".mkv", ".flv", ".f4v", ".rmvb", ".webm", ".hddvd", ".qsv",".vob"];
    var e_audio = [".cda", ".wav", ".mp3", ".wma", ".ra", ".rma", ".mid", ".wma", ".asf"];
    var e_rar = ['.rar', '.tar', '.zip', '.gzip', '.cab', '.uue', '.arj', '.bz2', '.lzh', '.jar', '.ace', '.war', '.iso', '.7z', '.gz'];
    var e_pdf = ['.pdf'];
    var e_text = ['.txt'];
    var e_word = ['.doc', '.docx', '.dot', '.dotx', '.docm'];
    var e_excel = ['.xls', '.xlsx', '.xlsm', '.xlt', '.xltx', '.xltm', '.ods', '.xlsd', '.xlam'];
    var e_ppt = ['.pptx', '.pptm', '.ppsx', '.potx', '.potm', '.ppam'];
    var real_type_list = [e_img,e_video,e_audio,e_rar,e_pdf,e_text,e_word,e_excel,e_ppt];
    var style_sheet = ['image', 'video', 'audio', 'zip', 'pdf', 'txt', 'doc', 'excel', 'ppt', 'other'];
    let name = '';
    for(var i = 0;i<real_type_list.length;i++){
        if(real_type_list[i].includes(extname)){
            name = style_sheet[i];
            break
        }else{
            name = style_sheet[9]
        }
    }
    return name
}
export default {
    fileTypeMatch
}
